<%--
  Created by IntelliJ IDEA.
  User: hsy
  Date: 2023/6/3
  Time: 19:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script>
  function validateForm() {
    // 获取密码和确认密码输入框的值
    var newPassword = document.getElementById("newPassword").value;
    var confirmPassword = document.getElementById("confirmPassword").value;

    // 判断密码和确认密码是否一致
    if (newPassword !== confirmPassword) {
      alert("密码和确认密码不一致，请重新输入！");
      return false;
    }
    // 判断必填项是否都填写了
    var userName = document.getElementsByName("userName")[0].value;
    if (!userName && !newPassword) {
      alert("管理员名称和密码必须填写其中一个！");
      return false;
    }
    return true;
  }
</script>
<html>
<%--共同侧边栏--%>
<%@ include file="sidebar.jsp" %>
<%
  int adminID = Integer.parseInt(request.getParameter("AdminID"));
%>
<head>
  <title>修改管理员信息</title>
</head>
<link rel="stylesheet" type="text/css" href="css/adminModify.css">

<body>
<h2>
  <span>请</span>填<span>写要修改的字段,不修改则不写</span>
</h2>

<form action="AdminModify" method="post" onsubmit="return validateForm()">
  <label>管理员id:</label>
  <input type="number" name="adminID" value="<%=adminID%>" readonly>
  <label>管理员名称:</label>
  <input type="text" name="adminName" maxlength="25">
  <label>修改密码</label>
  <input type="password" maxlength="25" name="newPassword" id="newPassword">
  <label>确认密码</label>
  <input type="password" maxlength="25" name="confirmPassword" id="confirmPassword">
  <input type="submit"></input>
</form>


</body>
</html>
